<!DOCTYPE html>
<html lang="zh"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>查看订单</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/user_user/css/layui.css"  media="all">
  <link rel="stylesheet" type="text/css" href="/user_user/css/about.css">
  <script src="/user_user/js/jquery-3.3.1.min.js" charset="utf-8"></script>
  <script type="text/javascript" src="/user_user/js/about.js"></script>
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>订单信息确认</legend>
</fieldset>

<form class="layui-form" id="messForm" action="">
  <div class="layui-form-item" style="display: inline-block">
    <label class="layui-form-label">车牌：</label>
    <div class="layui-input-inline">
      <input type="text" name="title" id="account" th:value="${createOrder.userCar.carCard}" autocomplete="off" style="cursor: default" readonly class="layui-input">
    </div>
  </div>
  <div style="display: inline-block;margin-left: 150px">
    <div style="text-align: center">总价格:<span style="color: red;font-size: 25px" th:text="((${createOrder.userCar.carPrice})*((${createOrder.userOrder.getOrderVipSite()})+(${createOrder.userOrder.getOrderOrdinary()})+(${createOrder.userOrder.getOrderNoSite()})))"></span>元</div></div>
  <div class="layui-form-item">
    <label class="layui-form-label">路线：</label>
    <div class="layui-input-inline">
      <input type="text" name="date" id="date" th:value="${createOrder.userCar.carRoute}" oninput = "value=value.replace(/[^\d]/g,'')" readonly lay-verify="date" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
  <div class="passMess" id="passMess" style="border: 1px dashed black;padding-top: 30px;padding-bottom: 30px;border-radius: 5px;background-color: #F5F5F5"></div>
  </div>
  <div class="layui-form-item" pane="" style="margin-bottom: 0">
    <div class="layui-form-item">
    <label class="layui-form-label">紧急联系人：</label>
    <div class="layui-input-block">
      <select name="interest" lay-filter="aihao" id="contMess">
      </select>
    </div>
  </div>
  </div>
  <div class="msg-box-container" style="color: #FF0000;font-size: 12px;">
    <span class="msg-box" id="msg-box" hidden="hidden"></span>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button type="button" class="layui-btn" onclick="toBuy()">立即支付</button>
      <button type="button" class="layui-btn layui-btn-primary" onclick="(backabout())">返回</button>
    </div>
  </div>
</form>
<script src="/user_user/js/jquery-3.3.1.min.js" charset="utf-8"></script>
<script src="/user_user/js/layui.js" charset="utf-8"></script>
<script src="/user_user/js/orderDetailes.js" charset="utf-8"></script>
<script th:inline="javascript">
  $(function () {
    let conEdit=document.getElementById("passMess");
    let contMess=document.getElementById("contMess");
    var orderVipSite = [[${createOrder.userOrder.getOrderVipSite()}]];
    var orderOrdinary = [[${createOrder.userOrder.getOrderOrdinary()}]];
    var orderNoSite = [[${createOrder.userOrder.getOrderNoSite()}]];
    var passes = [[${createOrder.passes}]];
    var contacts = [[${createOrder.contacts}]];
    let htmStr2="";
    let htmlStr="";
    console.dir(contacts);
    for (let i = 0; i < contacts.length; i++) {
      htmStr2 +="<option value='"+contacts[i].contId+"'>"+contacts[i].contName+"</option>";
    }
    for (let i = 0; i < orderVipSite; i++) {
      htmlStr += "    <div class=\"layui-form-item\" pane=\"\" style=\"margin-bottom: 0\">\n" +
              "      <label class='layui-form-label'>一等座：</label>\n" +
              "      <div class='layui-input-block'>\n" +
              "        <select name='interest' lay-filter='aihao'>\n" ;
      for (let j = 0; j < passes.length; j++) {
        htmlStr += "          <option value='"+passes[j].passId+"'>"+passes[j].passName+"</option>\n";
      }
      htmlStr+="        </select>\n" +
      "      </div>\n" +
      "    </div>";
    }
    for (let i = 0; i < orderOrdinary; i++) {
      htmlStr += "    <div class=\"layui-form-item\" pane=\"\" style=\"margin-bottom: 0\">\n" +
              "      <label class='layui-form-label'>二等座：</label>\n" +
              "      <div class='layui-input-block'>\n" +
              "        <select name='interest' lay-filter='aihao'>\n" ;
      for (let j = 0; j < passes.length; j++) {
        htmlStr += "          <option value='"+passes[j].passId+"'>"+passes[j].passName+"</option>\n";
      }
      htmlStr+="        </select>\n" +
              "      </div>\n" +
              "    </div>";
    }
    for (let i = 0; i < orderNoSite; i++) {
      htmlStr += "    <div class=\"layui-form-item\" pane=\"\" style=\"margin-bottom: 0\">\n" +
              "      <label class='layui-form-label'>无座：</label>\n" +
              "      <div class='layui-input-block'>\n" +
              "        <select name='interest' lay-filter='aihao'>\n" ;
      for (let j = 0; j < passes.length; j++) {
        htmlStr += "          <option value='"+passes[j].passId+"'>"+passes[j].passName+"</option>\n";
      }
      htmlStr+="        </select>\n" +
              "      </div>\n" +
              "    </div>";
    }
    contMess.innerHTML = htmStr2;
    conEdit.innerHTML=htmlStr;
    layui.use('form', function () {
      var form = layui.form;
      form.render()
    })
  })
  function toBuy(){
    var orderId = [[${createOrder.userOrder.getOrderId()}]];
    let orderPerson = $('#contMess').val();
    $.ajax({
      url: window.location.protocol+"//"+window.location.host+"/user/toBuy",
      type:"POST",
      async:false,
      data:JSON.stringify({"orderId":orderId,"orderPerson":orderPerson}),
      contentType:"application/json;charset=UTF-8",
      success:function(data){
        switch (data.code){
          case "0000":
            alert(data.msg);
            location.href="about";
            break;
          case "1111":
            showPopup("购买成功！");
        }
      },
      error:function(){
        alert("请求错误了");
      }
    });
  }
</script>
</body>
</html>